using System;
using System.Collections.Generic;
using System.Text;
using PluginManager;
using PluginManager.Events;

namespace TestPlugin
{
    [Plugin("Window 1","1.0","James","Gibphone","A Test")]
    public class Plugin1 : CoreEventListener
    {
        //frmMain f;
        public Plugin1()
        {
            //f = new frmMain();
            //f.Tag = this;
            //f.Show();
        }
        public event NotifyCore onEvent;
        public void onMessage(object sender, MessageArgs e)
        {
            //f.lblText.Text = e.Message;
        }
        public void OnLoad(object sender, EventArgs e)
        {
            RegisterCommands();
            Console.WriteLine("Plugin1 loaded successfully");
        }
        public void OnUnload(object sender, EventArgs e)
        {
            Console.WriteLine("Plugin1 unloaded successfully");
        }
        public void RegisterCommands()
        {
            PluginManager.Core.RegisterCommand(this, "test");
            PluginManager.Core.RegisterCommand(this, "test1");
        }
        public void OnCommand(object sender, CommandEventArgs e)
        {
            ExecuteCommand(e.Command,e.Parameters);
        }
        public void ExecuteCommand(string command, string[] parameters)
        {
            switch (command)
            {
                case "test":
                    Console.WriteLine("test command executed!");
                    break;
                case "test1":
                    Console.WriteLine("test1 command executed!");
                    break;
            }
        }
        public override void Dispose()
        {
            //f.Dispose();
        }
    }
    public class MessageArgs : EventArgs
    {
        public string Message;
        public MessageArgs(string s) { Message = s; }
    }
    [Plugin("Window 2", "1.0", "James", "Gibphone", "A Test")]
    public class Plugin2 : CoreEventListener
    {
        //frmMain f;
        public Plugin2()
        {
            //f = new frmMain();
            //f.Tag = this;
            //f.Show();
        }
        public event NotifyCore onEvent;
        public void onMessage(object sender, MessageArgs e)
        {
            //f.lblText.Text = e.Message;
        }
        public void OnLoad(object sender, EventArgs e)
        {
            RegisterCommands();
            Console.WriteLine("Plugin2 loaded successfully");
        }
        public void OnUnload(object sender, EventArgs e)
        {
            Console.WriteLine("Plugin2 unloaded successfully");
        }
        public void RegisterCommands()
        {
            PluginManager.Core.RegisterCommand(this, "test3");
            PluginManager.Core.RegisterCommand(this, "test4");
        }
        public void OnCommand(object sender, CommandEventArgs e)
        {
            ExecuteCommand(e.Command, e.Parameters);
        }
        public void ExecuteCommand(string command, string[] parameters)
        {
            switch (command)
            {
                case "test3":
                    Console.WriteLine("test3 command executed!");
                    break;
                case "test4":
                    Console.WriteLine("test4 command executed!");
                    break;
            }
        }
        public override void Dispose()
        {
            //f.Dispose();
        }
    }
}
